package org.example.com.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class FirstAdvice {
    @Pointcut("execution(* org.example.com.targer.*.*(..))")
    private void aa(){}

    @AfterReturning("aa()")
    public void afterReturn(){
        System.out.println("afterReturn,之后");
    }

    @Before("aa()")
    public void before(){
        System.out.println("before,之前");
    }

    @Around("aa()")
    public Object around(ProceedingJoinPoint Point) throws Throwable {
        System.out.println("huanrao之前");
        Object result = Point.proceed();
        System.out.println("huanrao之后");
        return result;
    }

    @After("aa()")
    public void after(){
        System.out.println("最终的通知");
    }

    @AfterThrowing("aa()")
    public void exception(){
        System.out.println("代码出现异常");
    }
}
